//
//  QuestionBottomView.m
//  PigMarket
//
//  Created by Felix on 2019/4/4.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "QuestionBottomView.h"

@interface QuestionBottomView ()

/**
 topLine
 */
@property (nonatomic , strong) UILabel *topLine;
/**
 leftView
 */
@property (nonatomic , strong) UIView *leftView;
/**
 leftIcon
 */
@property (nonatomic , strong) UIImageView *leftIcon;
/**
 leftTitle
 */
@property (nonatomic , strong) UILabel *leftTitle;
/**
 leftDetail
 */
@property (nonatomic , strong) UILabel *leftDetail;

/**
 centerLine
 */
@property (nonatomic , strong) UILabel *centerLine;
/**
 rightView
 */
@property (nonatomic , strong) UIView *rightView;
/**
 rightIcon
 */
@property (nonatomic , strong) UIImageView *rightIcon;
/**
 rightTitle
 */
@property (nonatomic , strong) UILabel *rightTitle;
/**
 rightDetail
 */
@property (nonatomic , strong) UILabel *rightDetail;

@end

@implementation QuestionBottomView

#pragma mark - init method

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor colorWithHexString:@"#ffffff"];
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self addSubview:self.topLine];
    
    [self addSubview:self.leftView];
    [self.leftView addSubview:self.leftIcon];
    [self.leftView addSubview:self.leftTitle];
    [self.leftView addSubview:self.leftDetail];
    
    [self addSubview:self.rightView];
    [self.rightView addSubview:self.rightIcon];
    [self.rightView addSubview:self.rightTitle];
    [self.rightView addSubview:self.rightDetail];
    
    [self addSubview:self.centerLine];
}

- (void)initLayout {
    // 布局子控件
    [self.topLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
    }];
    [self.leftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.mas_equalTo(0);
        make.top.mas_equalTo(self.topLine.mas_bottom);
        make.width.mas_equalTo(SCREEN_WIDTH/2);
    }];
    [self.leftTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(8);
        make.centerX.mas_equalTo(self.leftView.mas_centerX).offset(10);
    }];
    [self.leftIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.leftTitle.mas_centerY);
        make.right.mas_equalTo(self.leftTitle.mas_left).offset(-6);
    }];
    [self.leftDetail mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.leftTitle.mas_bottom).offset(4);
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo(-8);
    }];
    [self.rightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(self.topLine.mas_bottom);
        make.width.mas_equalTo(SCREEN_WIDTH/2);
    }];
    [self.rightTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(8);
        make.centerX.mas_equalTo(self.rightView.mas_centerX).offset(10);
    }];
    [self.rightIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.rightTitle.mas_centerY);
        make.right.mas_equalTo(self.rightTitle.mas_left).offset(-6);
    }];
    [self.rightDetail mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.rightTitle.mas_bottom).offset(4);
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo(-8);
    }];
    [self.centerLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(8);
        make.bottom.mas_equalTo(-8);
        make.width.mas_equalTo(0.5);
        make.centerX.mas_equalTo(self.mas_centerX);
    }];
}

#pragma mark - getter and setter

- (UILabel *)topLine {
    if (!_topLine) {
        _topLine = [[UILabel alloc] init];
        _topLine.backgroundColor = [UIColor dividerColor];
    }
    return _topLine;
}
- (UIView *)leftView {
    if (!_leftView) {
        _leftView = [[UIView alloc] init];
    }
    return _leftView;
}
- (UIImageView *)leftIcon {
    if (!_leftIcon) {
        _leftIcon = [[UIImageView alloc] init];
        _leftIcon.image = [UIImage imageNamed:@"system_question_onlineservice"];
    }
    return _leftIcon;
}
- (UILabel *)leftTitle {
    if (!_leftTitle) {
        _leftTitle = [[UILabel alloc] init];
        _leftTitle.textColor = [UIColor colorWithHexString:@"#262626"];
        _leftTitle.font = [UIFont systemFontOfSize:15];
        _leftTitle.text = @"在线客服";
    }
    return _leftTitle;
}
- (UILabel *)leftDetail {
    if (!_leftDetail) {
        _leftDetail = [[UILabel alloc] init];
        _leftDetail.textColor = [UIColor colorWithHexString:@"#999999"];
        _leftDetail.font = [UIFont systemFontOfSize:12];
        _leftDetail.text = @"24小时在线为您答疑";
    }
    return _leftDetail;
}
- (UILabel *)centerLine {
    if (!_centerLine) {
        _centerLine = [[UILabel alloc] init];
        _centerLine.backgroundColor = [UIColor dividerColor];
    }
    return _centerLine;
}
- (UIView *)rightView {
    if (!_rightView) {
        _rightView = [[UIView alloc] init];
    }
    return _rightView;
}
- (UIImageView *)rightIcon {
    if (!_rightIcon) {
        _rightIcon = [[UIImageView alloc] init];
        _rightIcon.image = [UIImage imageNamed:@"system_question_advice"];
    }
    return _rightIcon;
}
- (UILabel *)rightTitle {
    if (!_rightTitle) {
        _rightTitle = [[UILabel alloc] init];
        _rightTitle.textColor = [UIColor colorWithHexString:@"#262626"];
        _rightTitle.font = [UIFont systemFontOfSize:15];
        _rightTitle.text = @"意见反馈";
    }
    return _rightTitle;
}
- (UILabel *)rightDetail {
    if (!_rightDetail) {
        _rightDetail = [[UILabel alloc] init];
        _rightDetail.textColor = [UIColor colorWithHexString:@"#999999"];
        _rightDetail.font = [UIFont systemFontOfSize:12];
        _rightDetail.text = @"请提出您宝贵的建议";
    }
    return _rightDetail;
}

@end
